package lesson15;

public class Car 
{
	String model;
	int maxSpeed;
	int currentSpeed;
	String color;
	byte currentGear;
	Person owner;
	double price;
	boolean sportCar;
	
	double sellCarForScrap()
	{
		double metalPrice = 0.37;
		return metalPrice;
	}
	
	
	
	void changeOwner(Person newOwner)
	{
		this.owner = newOwner;
	}
	
	
	boolean isMoreExpensive(Car car)
	{	
		return this.price > car.price;
	}
	
	double calculateCarPriceForScrap(double metalPrice)
	{
		double coef = 0.2; 
		if(color.equals("black"))
		{
			coef +=0.05;
		}
		if(sportCar == true)
		{
			coef+=0.05;
		}
		return metalPrice*coef;
	}
	
	
	
	Car(String model, boolean sportCar, String color )
	{
		
		this.model = model;
		this.color = color;
	}
	Car(String model, boolean sportCar, String color, double price, int maxSpeed)
	{
		this(model, sportCar, color);
		this.model = model;
		this.color = color;
		this.price = price;
		
		if(maxSpeed > 200 && sportCar == true)
		{
			this.sportCar = sportCar;
			this.maxSpeed = maxSpeed;
		} 
		else
		{
			this.sportCar = false;
		}
	}
	
	void accelerate()
	{
		currentSpeed += 10;
		if(currentSpeed >= maxSpeed)
		{
			currentSpeed = maxSpeed;
		}
	}
	
	void changeGearUp()
	{
		if(currentGear <=5)
		{
			currentGear++;
		}
	}
	
	void changeGearDown()
	{
		if (currentGear >0) 
		{
			currentGear--;
		}
	}
	
	void changeGear(int nextGear)
	{
		if(currentSpeed >30 || currentSpeed < 60)
		{
			currentGear = 2;
		}
		else if (currentSpeed >= 60 || currentSpeed <100) 
		{
			currentGear = 3;
		}
		else if(currentSpeed >= 100 || currentSpeed < 130)
		{
			currentGear = 4;
		}
		else if(currentSpeed >= 130)
		{
			currentGear = 5;
		}
		else
		{
			
		}
	}
	
}
